<template>
<el-drawer :title="formDrawer.title" :visible.sync="formDrawer.visible" direction="rtl" custom-class="drawer-right-side">
    <div class="message-item-list">
        <div class="message-item" v-for="(item,index) in messageList" :key="index">
            <div>{{item.from_user_id}}</div>
            <div>{{item.content}}</div>
        </div>
    </div>

    <el-form ref="form" :model="form" label-width="10px">
        <el-form-item>
            <el-input type="textarea" v-model="form.content"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">发送</el-button>
            <el-button>取消</el-button>
        </el-form-item>
    </el-form>
</el-drawer>
</template>

<script>
import {
    mapGetters
} from "vuex";

let form = {
    from_user_id: "",
    target_user_id: "",
    content: "",
    type: "broadcast"
};

export default {
    computed: {
        ...mapGetters(["messageList"]),
    },
    data() {
        return {
            formDrawer: {
                title: "内部沟通",
                visible: false
            },
            form: Object.assign({}, form)
        }
    },
    methods: {
        showDrawer() {
            this.form = Object.assign({}, form)
            this.formDrawer.visible = true
        },
        onSubmit() {
            this.$socket.send(this.form)
        }
    }
}
</script>
